package homework.day13;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class test1 {
    public static void main(String[] args) {
        BufferedReader in = null;
        HashMap<String, Integer> hash = new HashMap<>();
        try {
            in = new BufferedReader(new FileReader("/Users/jinnian/Desktop/calcCharNum.txt"));
            while (true) {
                String s = in.readLine();
                if (s == null)
                    break;
                char[] a = s.toCharArray();
                for (char i : a) {
                    String str = String.valueOf(i);
                    if (hash.get(str) != null) {
                        Integer sum = hash.get(str);
                        sum += 1;
                        hash.put(str, sum);
                    } else {
                        hash.put(str, 1);
                    }
                }
            }
            Set<Map.Entry<String, Integer>> entries = hash.entrySet();
            Iterator<Map.Entry<String, Integer>> integers = entries.iterator();
            while (integers.hasNext()) {
                Map.Entry<String, Integer> entry = integers.next();
                System.out.println(entry.getKey() + "(" + entry.getValue() + ")");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
